# Untitled - By: lenovo - Mon Sep 9 2024


import time
from pyb import Servo


# 伺服系统需要 50 Hz PWM，脉冲宽度为 1000us 至 2000us。
# PWM支持的引脚有P7 P8 P9
s1 = Servo(1) # P7
s2 = Servo(2) # P8

while(True):
    for i in range(1000):
        s1.pulse_width(1000 + i)
        s2.pulse_width(1999 - i)
        time.sleep_ms(10)
    for i in range(1000):
        s1.pulse_width(1999 - i)
        s2.pulse_width(1000 + i)
        time.sleep_ms(10)
